package org.mcb.zebra.portal.resource;

import java.util.Set;
import java.util.TreeSet;

import org.mcb.zebra.portal.page.ZebPage;
import org.mcb.zebra.portal.page.PageManager;
import org.mcb.zebra.portal.page.ZebPageManager;

@SuppressWarnings("unchecked")
public class ZebResourceConfig implements ResourceConfig {
	private String portalInfo;
	private Set supportedPortletModes = new TreeSet();
	private Set supportedWindowStates =new TreeSet();
	private PageManager pageManager = new  ZebPageManager();

	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.resource.ResourceConfig#getPortalInfo()
	 */
	public String getPortalInfo() {
		return portalInfo;
	}

	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.resource.ResourceConfig#setPortalInfo(java.lang.String)
	 */
	public void setPortalInfo(String portalInfo) {
		this.portalInfo = portalInfo;
	}

	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.resource.ResourceConfig#getSupportedPortletModes()
	 */
	public Set getSupportedPortletModes() {
		return supportedPortletModes;
	}

	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.resource.ResourceConfig#getSupportedWindowStates()
	 */
	public Set getSupportedWindowStates() {
		return supportedWindowStates;
	}
	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.resource.ResourceConfig#addSupportedPortletMode(java.lang.String)
	 */
	public void addSupportedPortletMode(String portletMode) {
		supportedPortletModes.add(portletMode);
	}
	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.resource.ResourceConfig#addSupportedWindowState(java.lang.String)
	 */
	public void addSupportedWindowState(String portletState) {
		supportedWindowStates.add(portletState);
	}

	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.resource.ResourceConfig#setSupportedPortletModes(java.util.Set)
	 */
	public void setSupportedPortletModes(Set supportedPortletModes) {
		this.supportedPortletModes = supportedPortletModes;
	}

	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.resource.ResourceConfig#setSupportedWindowStates(java.util.Set)
	 */
	public void setSupportedWindowStates(Set supportedWindowStates) {
		this.supportedWindowStates = supportedWindowStates;
	}
	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.resource.ResourceConfig#addPage(org.mcb.zebra.portal.page.ZebPage)
	 */
	public void addPage(ZebPage page){
		if(page!=null)
			pageManager.addPage(page.getPageName(), page);
	}

	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.resource.ResourceConfig#getPageManager()
	 */
	public PageManager getPageManager() {
		return pageManager;
	}

	/* (non-Javadoc)
	 * @see org.mcb.zebra.portal.resource.ResourceConfig#setPageManager(org.mcb.zebra.portal.page.PageManager)
	 */
	public void setPageManager(PageManager pageManager) {
		this.pageManager = pageManager;
	}
	public void setDefaultPage(String pageName){
		pageManager.setDefaultPage(pageName);
	}
}
